package com.xxxx.controller;

import com.xxxx.entity.vo.MessageModel;
import com.xxxx.service.ResetService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/reset")
public class ResetServlet extends HttpServlet {
    private ResetService resetService = new ResetService();

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String uname = request.getParameter("uname");
        String upwd = request.getParameter("upwd");
        MessageModel messageModel = resetService.userReset(upwd,uname);
        if(messageModel.getCode()==1){
            response.sendRedirect("login.jsp");
        }else{
            request.setAttribute("messageModel",messageModel);
            request.getRequestDispatcher("reset.jsp").forward(request,response);
        }
    }
}